﻿
        $(function () {
            $.post("../BLL/City.ashx", { "action": "GetOneCity" }, function (data, status) {
                if (status == "success") {
                    var city = $.parseJSON(data);
                    var option = '<option value=' + city.SelfCode + '>' + city.Name + '</option>';
                    $("#city").empty();
                    $("#city").append(option);

                    $("#HidCityName").val(city.Name);
                    $("#HidCityCode").val(city.SelfCode);
                }
                $.post("../BLL/County.ashx", { "action": "GetCountyList", "cityCode": city.SelfCode }, function (data, status) {
                    if (status == "success") {
                        var county = $.parseJSON(data);
                        for (var i = 0; i < county.length; i++) {
                            var option = '<option value=' + county[i].SelfCode + '>' + county[i].Name + '</option>';
                            $("#county").append(option);
                        }
                    }
                });
            });

            $("#county").change(function () {
                $("#HidCountyCode").val($(this).val());
                $("#HidCountyName").val($(this).find("option:selected").text());
                
            });

            //检查用户名是否存在
            $("#txtUserName").focusout(function () {
                var username = $(this).val();
                $.post("../Bll/UsersAsh.ashx", { "action": "IsUserName", "username": username }, function (data, status) {
                    if (status == "success") {
                        var result = data;
                        if (result == "ok") {
                            $("#lbUserName").html("该用户已存在");
                            $("#txtUserName").focus();
                            return;
                        }
                    }
                });
            });

        });
